# 二分查找：默认有序数组，折半进行查询某个数的位置，如果不存在则返回-1
"""

"""

def half_search(li, num):
    l = 0
    r = len(li)-1
    while l <= r:
        mid_index = (l + r) // 2
        if li[mid_index] > num:
            r = mid_index-1
        elif li[mid_index] == num:
            return mid_index
        else:
            l = mid_index+1

    return -1








if __name__ == '__main__':
    li = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
    result = half_search(li, 13)
    print(result)
